/* 
* @Author: jade
* @Date:   2015-09-10 11:47:46
* @Last Modified by:   jade
* @Last Modified time: 2015-09-10 11:48:08
*/

(function($){
    'use strict';
    var templateView = Backbone.View.extend({
        className: 'template-item',
        events: {
            'click': 'itemClickHandler'
        },
        initialize: function () {
            var self = this
            self.listenTo(self.model, 'change', self.render)
        },
        render: function () {
            var self = this
            var data = self.model.toJSON()

            self.$el.html(Mustache.render(itemTpl, data))

            return self
        },
        itemClickHandler: function () {
            var self = this
            var data = null
            var fileJSON = data = self.model.toJSON()
        }
    })

    var itemTpl = '' +
        '{{^isLinkView}}<span class="checkbox {{#isChecked}}checked{{/isChecked}}"></span>{{/isLinkView}}' +
        '<em class="ficon-{{fileIcon}}"></em>' +
        '<span class="filename">{{fileName}}</span>'
 
    App.modules.templateView = templateView;
})(jQuery);